package  katris.selenium.tests.applogic2;


import java.util.List;



import org.openqa.selenium.WebElement;

import  katris.selenium.tests.applogic.FilmHelper;
import  katris.selenium.tests.model.Film;

public class FilmHelper2 extends DriverBasedHelper implements FilmHelper {

  public FilmHelper2(ApplicationManager2 manager) {
    super(manager.getWebDriver());
  }

  @Override
  public void create(Film film) {
	  pages.internalPage.clickAddMovieLink();
	  pages.addNewDescriptionPage.ensurePageLoaded();
	  pages.addNewDescriptionPage.insertMovieData(film);
	  pages.addNewDescriptionPage.saveDescription();
	
  }

  @Override
  public void delete(Film film) {
	  pages.internalPage.openMovieInfo(film);
	  pages.shortMovieInfoPage.ensurePageLoaded();
	  pages.shortMovieInfoPage.clickRemoveDescription();

  }

  @Override
  public void search(Film basicFilm, Film film) {
	  pages.internalPage.cleanSearch();
	WebElement basic = pages.internalPage.rememberItem(basicFilm);
	  pages.internalPage.searchDescription(film);
	  pages.internalPage.waitUntilSearchFinish(basic);
  }
  
  @Override
  public boolean checkPresence(Film film) {
	  pages.internalPage.ensurePageLoaded();
    return pages.internalPage.descriptionIsPresent(film);
  }
  
  @Override
  public boolean checkNotPresence(Film film) {
	  pages.internalPage.ensurePageLoaded();
    return pages.internalPage.descriptionIsAbsent(film);
  }
  
  @Override
  public boolean checkShortInfo(Film film) {
	  pages.shortMovieInfoPage.ensurePageLoaded(); 
	  return pages.shortMovieInfoPage.checkMovieInfo(film);
  }
  
  @Override
  public boolean checkIfRequiredDataIsSet(){
	  pages.addNewDescriptionPage.ensurePageLoaded(); 
	  return pages.addNewDescriptionPage.checkWarningsForMandatoryFields();
  }

}
